// var initialState = {
//     userinfo: {
//         token: ''
//     },
//     collapsed: false,
//     keyPach: []
// }

// function reducer(state = initialState, action: any) {
//     var newState = JSON.parse(JSON.stringify(state))
//     if (action.type == 'SAVE_USERINFO') {
//         newState.userinfo = action.payload;
//         // console.log(newState);
//         return newState;
//     } else if (action.type == 'REMOVE_USERINFO') {
//         newState.userinfo = {}
//         return newState;
//     } else if (action.type == 'SAVE_TOKEN') {
//         newState.token = action.payload
//         return newState;
//     } else if (action.type == 'SAVE_COLLAPSED') {
//         newState.collapsed = !newState.collapsed;
//         return newState;
//     } else if (action.type == 'SAVE_KEYPACH') {
//         newState.keyPach = action.payload;
//         return newState;
//     } else {
//         return state;
//     }
// }

// export default reducer;

var initialState = {
    userinfo: {
        token: ''
    },
    collapsed: false,
    keyPach: [],
    AdminParticulars: {}
}

function reducer(state = initialState, action: any) {
    var newState = JSON.parse(JSON.stringify(state))
    if (action.type == 'SAVE_USERINFO') {
        newState.userinfo = action.payload;
        // console.log(newState);
        return newState;
    } else if (action.type == 'REMOVE_USERINFO') {
        newState.userinfo = {}
        return newState;
    } else if (action.type == 'SAVE_COLLAPSED') {
        newState.collapsed = !newState.collapsed;
        return newState;
    } else if (action.type == 'SAVE_KEYPACH') {
        newState.keyPach = action.payload;
        return newState;
    } else if (action.type === 'store_AdminPar') {
        newState.AdminParticulars = action.payload
        return newState
    } else {
        return state;
    }
}

export default reducer;